﻿namespace Commander.Core.Services
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Commander.Core.Interfaces.Shared;
    using Commander.Core.Services.Instantiations;

    /// <summary>
    /// Simple and quick IContainer implementation
    /// </summary>
    internal class QuickContainer : IContainer
    {
        private Builder m_builder = new Builder();

        #region IContainer Members

        public TInterface Get<TInterface>()
        {
            return Get<TInterface>(null);
        }

        public TInterface Get<TInterface>(object context)
        {
            return (TInterface)Get(typeof (TInterface), context);
        }

        public object Get(Type interfaceType)
        {
            return Get(interfaceType, null);
        }

        public object Get(Type interfaceType, object context)
        {
            return m_builder.Get(interfaceType, context);
        }

        public bool Has<TInterface>()
        {
            return Has<TInterface>(null);
        }

        public bool Has<TInterface>(object context)
        {
            return Has(typeof (TInterface), context);
        }

        public bool Has(Type interfaceType)
        {
            return Has(interfaceType, null);
        }

        public bool Has(Type interfaceType, object context)
        {
            return m_builder.Has(interfaceType, context);
        }

        public void SetUp<TInterface, TImplementation>() where TImplementation : TInterface
        {
            SetUp<TInterface, TImplementation>(null);
        }

        public void SetUp<TInterface, TImplementation>(object context) where TImplementation : TInterface
        {
            SetUp(typeof(TInterface), typeof(TImplementation), null);
        }

        public void SetUp(Type interfaceType, Type implementation)
        {
            SetUp(interfaceType, implementation, null);
        }

        public void SetUp(Type interfaceType, Type implementation, object context)
        {
            m_builder.SetUp(interfaceType, implementation, context);
        }

        #endregion        
    }
}
